package com.openscorer;

public class Scrabble implements Game {
	public String name() { return "Scrabble"; }
	public Scorable variables() {
		Structure struct = new Structure("data", FormattingOptions.invisible());
		struct.add(new Repeated(new Int("Word", null)));
		struct.add(new Int("Letters in Hand", null));
		return struct;
	}

	public double score(int player, Scorable[] data) {
		int hand_score = 0;
		if (data[player].get("Letters in Hand").num() == 0) {
			for (int i = 0; i < data.length; ++i) {
				hand_score += data[i].get("Letters in Hand").num();
			}
		} else {
			hand_score = - data[player].get("Letters in Hand").num();
		}
		int word_score = 0;
		for (int i = 0; i < data[player].get("Word").num_rounds(); ++i) {
			word_score += data[player].get("Word").round(i).num();
		}
		return word_score + hand_score;
	}
	public FormattingOptions formatScore() {
		return null;
	}
}
